package com.itawei.d3_mathdemo;

public class Mathapp {
    public static void main(String[] args) {
        test1();
        test2();
        test3();
    }
    public static void test1(){
        //判断有多少个2位自幂数 10-99
        for (int i = 10; i <= 99; i++) {
            //取个位数
            int ge = i % 10;
            //取十位数
            int shi = i / 10;
            double sum = Math.pow(ge, 2) + Math.pow(shi, 2);
            if (sum == i) {
                System.out.println(i);
            }
        }
    }

    public static void test2(){
        int count = 0;
        for (int i = 1000; i <= 9999 ; i++) {
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 100 % 10;
            int qian = i / 1000;
            double sum = Math.pow(ge, 4) + Math.pow(shi, 4) + Math.pow(bai, 4) + Math.pow(qian, 4);
            if (sum == i) {
                System.out.println(i);
                count++;
            }
        }
    }

    public static void test3(){
        int count = 0;
        //判断五位数
        for (int i = 10000; i <= 99999; i++) {
            int ge = i % 10;
            int shi = i / 10 % 10;
            int bai = i / 100 % 10;
            int qian = i / 1000 % 10;
            int wan = i / 10000 % 10;
            double sum = Math.pow(ge, 5) + Math.pow(shi, 5) + Math.pow(bai, 5) + Math.pow(qian, 5) + Math.pow(wan, 5);
            if(sum == i){
                System.out.println(i);
                count++;
            }
        }
    }
}
